// Smooth scroll para links de navegação document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); } }); }); // Header scroll effect let lastScroll = 0; const header = document.querySelector('.header'); window.addEventListener('scroll', () => { const currentScroll = window.pageYOffset; if (currentScroll > 100) { header.style.boxShadow = '0 4px 12px rgba(0, 0, 0, 0.15)'; } else { header.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)'; } lastScroll = currentScroll; }); // Intersection Observer para animações ao scroll const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); // Observar elementos para animação document.querySelectorAll('.produto-card, .diferencial-card, .sobre-content, .contato-content').forEach(el => { el.style.opacity = '0'; el.style.transform = 'translateY(30px)'; el.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; observer.observe(el); }); // Adicionar efeito de hover nos cards de produtos document.querySelectorAll('.produto-card').forEach(card => { card.addEventListener('mouseenter', function() { this.style.transform = 'translateY(-10px) scale(1.02)'; }); card.addEventListener('mouseleave', function() { this.style.transform = 'translateY(0) scale(1)'; }); }); // Adicionar efeito de hover nos diferenciais document.querySelectorAll('.diferencial-card').forEach(card => { card.addEventListener('mouseenter', function() { const icon = this.querySelector('.diferencial-icon'); icon.style.transform = 'rotate(360deg) scale(1.1)'; icon.style.transition = 'transform 0.6s ease'; }); card.addEventListener('mouseleave', function() { const icon = this.querySelector('.diferencial-icon'); icon.style.transform = 'rotate(0deg) scale(1)'; }); }); // Lazy loading para imagens if ('loading' in HTMLImageElement.prototype) { const images = document.querySelectorAll('img[loading="lazy"]'); images.forEach(img => { img.src = img.dataset.src; }); } else { // Fallback para navegadores que não suportam lazy loading const script = document.createElement('script'); script.src = 'https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.3.2/lazysizes.min.js'; document.body.appendChild(script); } // Adicionar animação ao botão flutuante do WhatsApp const whatsappFloat = document.querySelector('.whatsapp-float'); if (whatsappFloat) { whatsappFloat.addEventListener('mouseenter', function() { this.style.animation = 'none'; }); whatsappFloat.addEventListener('mouseleave', function() { this.style.animation = 'pulse 2s infinite'; }); } // Prevenção de scroll horizontal document.body.style.overflowX = 'hidden'; // Log de carregamento console.log('Tirze Farma - Site carregado com sucesso!'); console.log('WhatsApp: +55 11 5194-0139');